<?php
namespace App\Services\Titles;
use App\Model\Titles;
use App\Services\CommonService;
use Illuminate\Support\Facades\DB;
class TitlesService extends CommonService
{
    public function sel(&$data)
    {

        $TitlesInfo= Titles::where('test_id','=',$data)
            ->orderBy(DB::raw('RAND()'))
            ->take(18)
            ->get()
            ->toArray();

        if($TitlesInfo===array())
        {
            return $this->fail(209,'查询题失败');
        }
        foreach($TitlesInfo as &$v)
        {
            $v['title_option']=json_decode($v['title_option'],true);
        }
        return $this->success($TitlesInfo);
    }
}